﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;
using DelonixRegiaHMSys.Core.Models;

namespace DelonixRegiaHMSys.UI.WebForms.Run_and_Close
{
    public partial class StoreRoomOccupancy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var roservice = new roServices(new EfRoomQuery());
            var gpservice = new gpServices(new EfGuestParticularQuery());
            var reservice = new reServices(new EfReportQuery());
            DateTime date = DateTime.Now;
            string a = date.ToString("yyyy-MM-dd");
            date = Convert.ToDateTime(a);
            RoomOccupancyReport ro = new RoomOccupancyReport();
            string status = "O";
            var retrievedRoom = roservice.GetAllRoom(status);
            foreach (RoomDetails r in retrievedRoom)
            {
                ro.Date = date;
                ro.RoomNum = r.RoomNum;
                ro.GuestID = r.GuestID;
                var gp = gpservice.GetGuestbyID(ro.GuestID);
                reservice.InsertRO(ro);
            }
            ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);
        }
    }
}